#include "StringLib.h"
#include <sstream>
#include <stdarg.h>
#include <algorithm>
#include "Game.h"
#include "Util.h"

StringLib::StringLib(LanguageType type) {
	m_languageType = type;

	m_textStrings[LANG_ENG][ST_WELCOME] = "Welcome!";
	m_textStrings[LANG_ENG][ST_WELCOME2] = "Welcome back!";

	m_textStrings[LANG_ENG][ST_NPC_LEVEL_UP] = "The \t looks stronger.";
	m_textStrings[LANG_ENG][ST_NPC_EXPERIENCE_NEGATIVE] = "negatively experienced";
	m_textStrings[LANG_ENG][ST_NPC_EXPERIENCE_NORMAL] = "normally experienced";
	m_textStrings[LANG_ENG][ST_NPC_EXPERIENCE_SLIGHT] = "slightly experienced";
	m_textStrings[LANG_ENG][ST_NPC_EXPERIENCE_MODERATE] = "moderately experienced";
	m_textStrings[LANG_ENG][ST_NPC_EXPERIENCE_HEAVY] = "heavily experienced";
	m_textStrings[LANG_ENG][ST_NPC_EXPERIENCE_EXTREME] = "extremely experienced";
	m_textStrings[LANG_ENG][ST_NPC_EXPERIENCE_LEVEL] = "It appears to be \t.";
	m_textStrings[LANG_ENG][ST_NPC_EQUIP] = "The \t equips its \t.";
	m_textStrings[LANG_ENG][ST_NPC_UNEQUIP] = "The \t unequips its \t.";
	m_textStrings[LANG_ENG][ST_NPC_QUAFF] = "The \t drinks its \t.";
	m_textStrings[LANG_ENG][ST_NPC_HEAL] = "The \t looks healthier.";
	m_textStrings[LANG_ENG][ST_NPC_POISON_DAMAGE] = "The \t takes poison damage.";
	m_textStrings[LANG_ENG][ST_NPC_GENDER] = "It is \t.";
	m_textStrings[LANG_ENG][ST_NPC_GENDER_NONE] = "It has no gender.";
	m_textStrings[LANG_ENG][ST_NPC_HEALTH_STATUS] = "It is \t.";
	m_textStrings[LANG_ENG][ST_NPC_MELEE_NOTHING] = "The \t swings at nothing.";
	m_textStrings[LANG_ENG][ST_NPC_MELEE_MISS] = "The \t misses the \t.";
	m_textStrings[LANG_ENG][ST_NPC_MELEE_HIT] = "The \t hits the \t for \t damage..";
	m_textStrings[LANG_ENG][ST_NPC_MELEE_BLOCKED] = "The \t's attack is blocked by the \t.";
	m_textStrings[LANG_ENG][ST_NPC_MELEE_CRIT] = "The \t scores a critical hit!";
	m_textStrings[LANG_ENG][ST_NPC_MELEE_FLAME] = "The \t's weapon scorches the \t.";
	m_textStrings[LANG_ENG][ST_NPC_MELEE_ENVY] = "The \t's weapon somehow exploits the \t's weakness.";
	m_textStrings[LANG_ENG][ST_NPC_MELEE_LUST] = "The \t's gender enrages the \t.";
	m_textStrings[LANG_ENG][ST_NPC_MELEE_MISS_PLAYER] = "The \t misses you.";
	m_textStrings[LANG_ENG][ST_NPC_MELEE_HIT_PLAYER] = "The \t hits you for \t damage.";
	m_textStrings[LANG_ENG][ST_NPC_MELEE_BLOCKED_PLAYER] = "You block the \t's attack.";
	m_textStrings[LANG_ENG][ST_NPC_MELEE_FLAME_PLAYER] = "The \t's weapon scorches you.";
	m_textStrings[LANG_ENG][ST_NPC_MELEE_ENVY_PLAYER] = "The \t's weapon somehow exploits your weakness.";
	m_textStrings[LANG_ENG][ST_NPC_MELEE_LUST_PLAYER] = "Your gender enrages the \t.";
	m_textStrings[LANG_ENG][ST_NPC_STATUS_EFFECT_GAIN] = "The \t gains the effect of \t.";
	m_textStrings[LANG_ENG][ST_NPC_STATUS_EFFECT_COMPOUND] = "The \t's \t effect is compounded.";
	m_textStrings[LANG_ENG][ST_NPC_STATUS_EFFECT_LOSE] = "The \t loses the effect of \t.";
	m_textStrings[LANG_ENG][ST_NPC_TRAP_DAGGER_HIT] = "A \r3dagger\r3 launches from the \r4trap\r4, hitting the \t for \t damage.";
	m_textStrings[LANG_ENG][ST_NPC_TRAP_DAGGER_MISS] = "A \r3dagger\r3 launches from the \r4trap\r4, but misses the \t.";
	m_textStrings[LANG_ENG][ST_NPC_OPEN_DOOR] = "The \t opens the door.";
	m_textStrings[LANG_ENG][ST_NPC_HAS_ITEM_EQUIPPED] = "\t has equipped:";
	m_textStrings[LANG_ENG][ST_NPC_RELOAD] = "The \t reloads its \t.";

	m_textStrings[LANG_ENG][ST_PLAYER_SATIATION_CHANGE_STARVING] = "You are starving.";
	m_textStrings[LANG_ENG][ST_PLAYER_SATIATION_CHANGE_VERY_HUNGRY] = "You feel very hungry.";
	m_textStrings[LANG_ENG][ST_PLAYER_SATIATION_CHANGE_HUNGRY] = "You feel hungry.";
	m_textStrings[LANG_ENG][ST_PLAYER_EQUIP] = "You equip your \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_UNEQUIP] = "You unequip your \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_EQUIP_FAIL] = "You could not equip your \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_UNEQUIP_FAIL] = "You could not unequip your \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_DROP] = "You drop your \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_PICK_UP] = "You picked up the \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_PICK_UP_FAIL] = "You're not strong enough to pick up the \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_GAIN_STR] = "You grow stronger.";
	m_textStrings[LANG_ENG][ST_PLAYER_LOSE_STR] = "You feel weaker.";
	m_textStrings[LANG_ENG][ST_PLAYER_GAIN_COM] = "You become more calm.";
	m_textStrings[LANG_ENG][ST_PLAYER_LOSE_COM] = "Fear inhabits you more easily.";
	m_textStrings[LANG_ENG][ST_PLAYER_GAIN_NIM] = "You feel light on your toes.";
	m_textStrings[LANG_ENG][ST_PLAYER_LOSE_NIM] = "You're not as quick as you once were.";
	m_textStrings[LANG_ENG][ST_PLAYER_GAIN_LOR] = "You become more learned about the arcane.";
	m_textStrings[LANG_ENG][ST_PLAYER_LOSE_LOR] = "Arcane knowledge is more difficult for you to understand.";
	m_textStrings[LANG_ENG][ST_PLAYER_GAIN_PER] = "Your eyesight sharpens.";
	m_textStrings[LANG_ENG][ST_PLAYER_LOSE_PER] = "Your eyesight worsens.";
	m_textStrings[LANG_ENG][ST_PLAYER_QUAFF] = "You drink the \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_EAT] = "You eat the \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_EAT_CURSED] = "Yuck! This tastes disgusting.";
	m_textStrings[LANG_ENG][ST_PLAYER_EAT_BLESSED] = "This tastes unusually good.";
	m_textStrings[LANG_ENG][ST_PLAYER_HEAL] = "You look healthier.";
	m_textStrings[LANG_ENG][ST_PLAYER_POISON_DAMAGE] = "You take poison damage.";
	m_textStrings[LANG_ENG][ST_PLAYER_GENDER] = "You are \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_GENDER_NONE] = "You have no gender.";
	m_textStrings[LANG_ENG][ST_PLAYER_HEALTH_STATUS] = "You are \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_MELEE_NOTHING] = "You swing at nothing.";
	m_textStrings[LANG_ENG][ST_PLAYER_MELEE_MISS] = "You miss the \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_MELEE_HIT] = "You hit the \t for \t damage.";
	m_textStrings[LANG_ENG][ST_PLAYER_MELEE_BLOCKED] = "The \t blocks your attack.";
	m_textStrings[LANG_ENG][ST_PLAYER_MELEE_CRIT] = "You score a critical hit!";
	m_textStrings[LANG_ENG][ST_PLAYER_MELEE_FLAME] = "Your weapon scorches the \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_MELEE_ENVY] = "You somehow exploit the \t's weakness.";
	m_textStrings[LANG_ENG][ST_PLAYER_MELEE_LUST] = "The \t's gender enrages you.";
	m_textStrings[LANG_ENG][ST_PLAYER_STATUS_EFFECT_GAIN] = "You gain the effect of \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_STATUS_EFFECT_COMPOUND] = "Your \t effect is compounded.";
	m_textStrings[LANG_ENG][ST_PLAYER_STATUS_EFFECT_LOSE] = "You lose the effect of \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_KICK_NOTHING] = "You kick at nothing.";
	m_textStrings[LANG_ENG][ST_PLAYER_KICK_LOCK_SUCCEED] = "You kick the lock. The lock cracks and falls off the \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_KICK_LOCK_FAIL] = "You kick the lock. Unfortunately, you've broken it beyond repair.";
	m_textStrings[LANG_ENG][ST_PLAYER_KICK_DESTROY_RESOURCE] = "You kick the \t and destroy a resource.";
	m_textStrings[LANG_ENG][ST_PLAYER_KICK_STUB] = "Ouch! You stub your toe.";
	m_textStrings[LANG_ENG][ST_PLAYER_KICK_ITEM_SLIDE_SUCCEED] = "You kick the \t and it slides across the ground.";
	m_textStrings[LANG_ENG][ST_PLAYER_KICK_ITEM_SLIDE_FAIL] = "You kick the \t but it doesn't move.";
	m_textStrings[LANG_ENG][ST_PLAYER_TRAP_DAGGER_HIT] = "A \r3dagger\r3 launches from the \r4trap\r4, hitting you for \t damage.";
	m_textStrings[LANG_ENG][ST_PLAYER_TRAP_DAGGER_MISS] = "A \r3dagger\r3 launches from the \r4trap\r4, but misses you.";
	m_textStrings[LANG_ENG][ST_PLAYER_ASCEND_SUCCESS] = "You escape with the \t!";
	m_textStrings[LANG_ENG][ST_PLAYER_ASCEND_FAIL] = "You can't ascend without the \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_LOCK_UNLOCK] = "You \t the \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_OPEN_CLOSE_DOOR] = "You \t the \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_READ_SCROLL] = "You read the \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_IDENTIFY] = "It is \n \t";
	m_textStrings[LANG_ENG][ST_PLAYER_IDENTIFY_ALL] = "You suddenly understand the function of your items.";
	m_textStrings[LANG_ENG][ST_PLAYER_UNCURSE] = "The \t is no longer cursed.";
	m_textStrings[LANG_ENG][ST_PLAYER_UNCURSE_ALL] = "You feel a heavy weight lifted from your inventory.";
	m_textStrings[LANG_ENG][ST_PLAYER_LEVEL_UP] = "Your level has gone up to level \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_TALENT] = "You have gained the talent: \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_ROTTING] = "Something in your inventory is rotting.";
	m_textStrings[LANG_ENG][ST_PLAYER_ROTTED] = "Your inventory feels lighter.";
	m_textStrings[LANG_ENG][ST_PLAYER_SKILL_UP] = "Your skill in \t has increased to level \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_STARVED] = "You have starved to death.";
	m_textStrings[LANG_ENG][ST_PLAYER_RELOAD] = "You reload your \t.";
	m_textStrings[LANG_ENG][ST_PLAYER_RELOAD_NO_AMMO] = "You can't reload the \t because you don't have any \t.";

	m_textStrings[LANG_ENG][ST_TILE_SEE_SINGLE] = "You see \n \t here.";
	m_textStrings[LANG_ENG][ST_TILE_SEE_MULTIPLE] = "You see several items here.";

	m_textStrings[LANG_ENG][ST_OBSTACLE_STAND] = "You are able to stand on this tile.";
	m_textStrings[LANG_ENG][ST_OBSTACLE_BLOCKED] = "You cannot stand on this tile.";

	m_textStrings[LANG_ENG][ST_IC_SHATTER] = "The \t shatters.";
	m_textStrings[LANG_ENG][ST_IC_HIDDEN_MONSTER] = "\n \t was hidden inside the \t.";
	m_textStrings[LANG_ENG][ST_IC_HIDDEN_ITEM] = "You find \n \t hidden inside the \t.";
	m_textStrings[LANG_ENG][ST_IC_LOCK_TYPE] = "This \t has a \t lock.";
	m_textStrings[LANG_ENG][ST_IC_LOCKED] = "This \t is \t.";

	m_textStrings[LANG_ENG][ST_DOOR_LOCK_TYPE] = "This door has a \t lock.";
	m_textStrings[LANG_ENG][ST_DOOR_LOCKED] = "This door is \t.";
	m_textStrings[LANG_ENG][ST_DOOR_OPEN] = "This door is currently \t.";

	m_textStrings[LANG_ENG][ST_LOCK_DESTROYED] = "This \t cannot be opened because the lock was destroyed.";

	m_textStrings[LANG_ENG][ST_RESOURCE_NUM_LEFT] = "You can gather from this resource \t more times.";
	m_textStrings[LANG_ENG][ST_RESOURCE_HARDNESS] = "This resource cannot be gathered without a tool with a hardness of at least \t.";
	m_textStrings[LANG_ENG][ST_RESOURCE_HEALTH] = "This node has \t health left before a resource can be gathered.";
	m_textStrings[LANG_ENG][ST_RESOURCE_DAMAGE_PLANT] = "You destroy a \t.";
	m_textStrings[LANG_ENG][ST_RESOURCE_DAMAGE] = "Your tools are not advanced enough to gather this resource.";
	m_textStrings[LANG_ENG][ST_RESOURCE_GATHER] = "You gather \n \t.";
	m_textStrings[LANG_ENG][ST_RESOURCE_GATHER_RARE] = "You gather a rare \t!";
	m_textStrings[LANG_ENG][ST_RESOURCE_GATHER_NONE] = "You didn't gather anything.";
	m_textStrings[LANG_ENG][ST_RESOURCE_GATHER_ATTEMPT] = "You try to gather ingredients from the \t using your \t.";

	m_textStrings[LANG_ENG][ST_TRAP_EMPTY] = "This trap no longer poses a threat.";

	m_textStrings[LANG_ENG][ST_ITEM_WEIGHT] = "Weight: \t units";

	m_textStrings[LANG_ENG][ST_POTION_POWER] = "Power: \t";
	m_textStrings[LANG_ENG][ST_POTION_SHATTER] = "The \t shatters.";

	m_textStrings[LANG_ENG][ST_TOOL_STATS] = "Tool power: \t   Tool speed: \t%";
	m_textStrings[LANG_ENG][ST_TOOL_HIGH_QUALITY] = "This tool is of exceptional quality.";

	m_textStrings[LANG_ENG][ST_QUAFF_WATER_CURSED] = "Yuck! This water tastes terrible.";
	m_textStrings[LANG_ENG][ST_QUAFF_WATER_UNCURSED] = "This tastes like ordinary water.";
	m_textStrings[LANG_ENG][ST_QUAFF_WATER_BLESSED] = "This water tastes delicious.";

	m_textStrings[LANG_ENG][ST_WEAPON_NUM_DICE] = "Number of dice: \t";
	m_textStrings[LANG_ENG][ST_WEAPON_DIE_SIDES] = "Sides per die: \t";
	m_textStrings[LANG_ENG][ST_WEAPON_ATTACK_BONUS] = "Attack bonus: \t";
	m_textStrings[LANG_ENG][ST_WEAPON_ACCURACY_BONUS] = "Accuracy bonus: \t";
	m_textStrings[LANG_ENG][ST_WEAPON_SPEED] = "Speed: \t%";
	m_textStrings[LANG_ENG][ST_WEAPON_MATERIAL] = "This weapon is made out of \t.";
	m_textStrings[LANG_ENG][ST_WEAPON_HIGH_QUALITY] = "This weapon is of exceptional quality.";
	m_textStrings[LANG_ENG][ST_WEAPON_AMMO] = "Loaded Ammo: \t/\t";
	m_textStrings[LANG_ENG][ST_WEAPON_AMMO_TYPE] = "Ammo Type: \t";
	m_textStrings[LANG_ENG][ST_WEAPON_RANGE] = "Range: \t";

	m_textStrings[LANG_ENG][ST_ARMOR_DODGE] = "Dodge Bonus: \t";
	m_textStrings[LANG_ENG][ST_ARMOR_ARMOR] = "Armor Bonus: \t";
	m_textStrings[LANG_ENG][ST_ARMOR_MATERIAL] = "This \t piece is made out of \t.";
	m_textStrings[LANG_ENG][ST_ARMOR_HIGH_QUALITY] = "This \t piece is made of exceptional quality.";
	m_textStrings[LANG_ENG][ST_SHIELD_BLOCK] = "Block rate: \t";
	m_textStrings[LANG_ENG][ST_SHIELD_MATERIAL] = "This shield is made out of \t.";
	m_textStrings[LANG_ENG][ST_SHIELD_HIGH_QUALITY] = "This shield is made of exceptional quality.";

	m_textStrings[LANG_ENG][ST_CRAFT_ITEM] = "You crafted \n \t.";
	m_textStrings[LANG_ENG][ST_CRAFT_ITEM_DETAILS] = "(\t) \t x\t \t";
	m_textStrings[LANG_ENG][ST_CRAFT_INSTRUCTIONS] = "Press (c) to craft, or escape to go back";

	m_textStrings[LANG_ENG][ST_INPUT_INVENTORY] = "Inventory";
	m_textStrings[LANG_ENG][ST_INPUT_DROP] = "Drop which items?";
	m_textStrings[LANG_ENG][ST_INPUT_LOCK_UNLOCK] = "Select which direction to attempt locking or unlocking.";
	m_textStrings[LANG_ENG][ST_INPUT_LOOT_CHEST] = "Loot chest";
	m_textStrings[LANG_ENG][ST_INPUT_QUAFF] = "Quaff which item?";
	m_textStrings[LANG_ENG][ST_INPUT_EAT] = "Eat which item?";
	m_textStrings[LANG_ENG][ST_INPUT_KICK] = "Select which direction to kick.";
	m_textStrings[LANG_ENG][ST_INPUT_VIEW_ITEM_STACK] = "View items";
	m_textStrings[LANG_ENG][ST_INPUT_EQUIP] = "Select item to equip for \t";
	m_textStrings[LANG_ENG][ST_INPUT_INGREDIENT] = "Select ingredient for \t";
	m_textStrings[LANG_ENG][ST_INPUT_CANCEL] = "Okay, then.";
	m_textStrings[LANG_ENG][ST_INPUT_PICK_UP_ASK] = "Do you want to pick up: \t? y/n/a/?,*";
	m_textStrings[LANG_ENG][ST_INPUT_PICK_UP_MULTIPLE] = "Pick up";
	m_textStrings[LANG_ENG][ST_INPUT_NO_KEY] = "You don't have the appropriate key.";
	m_textStrings[LANG_ENG][ST_INPUT_NO_LOCK] = "There is nothing with a lock in that tile.";
	m_textStrings[LANG_ENG][ST_INPUT_SCROLL] = "Read which item?";
	m_textStrings[LANG_ENG][ST_INPUT_SCROLL_ITEM] = "Select item to \t";
	m_textStrings[LANG_ENG][ST_INPUT_TALENT] = "Select talent";
	m_textStrings[LANG_ENG][ST_INPUT_SKILL] = "Select skill to increase";
	m_textStrings[LANG_ENG][ST_INPUT_NEW_SKILL] = "Select skill to learn";
	m_textStrings[LANG_ENG][ST_INPUT_NO_AMMO] = "Your weapon is not loaded.";
	m_textStrings[LANG_ENG][ST_INPUT_NO_RANGED] = "You don't have a ranged weapon equipped.";

	m_textStrings[LANG_ENG][ST_NOTHING] = "Nothing happens.";

	m_objectStrings[LANG_ENG][NUM_HIERARCHY_TYPES][TH_GENERIC_TYPE].push_back("Generic Type");
	m_objectStrings[LANG_ENG][NUM_HIERARCHY_TYPES][TH_PLAYER_TYPE].push_back("Player Type");
	m_objectStrings[LANG_ENG][NUM_HIERARCHY_TYPES][TH_NPC_TYPE].push_back("NPC Type");
	m_objectStrings[LANG_ENG][NUM_HIERARCHY_TYPES][TH_AMMO_TYPE].push_back("Ammo Type");
	m_objectStrings[LANG_ENG][NUM_HIERARCHY_TYPES][TH_ARMOR_FAMILY].push_back("Armor Family");
	m_objectStrings[LANG_ENG][NUM_HIERARCHY_TYPES][TH_ARMOR_TYPE].push_back("Armor Type");
	m_objectStrings[LANG_ENG][NUM_HIERARCHY_TYPES][TH_FOOD_TYPE].push_back("Food Type");
	m_objectStrings[LANG_ENG][NUM_HIERARCHY_TYPES][TH_INGREDIENT_FAMILY].push_back("Ingredient Family");
	m_objectStrings[LANG_ENG][NUM_HIERARCHY_TYPES][TH_INGREDIENT_TYPE].push_back("Ingredient Type");
	m_objectStrings[LANG_ENG][NUM_HIERARCHY_TYPES][TH_MISC_TYPE].push_back("Misc Type");
	m_objectStrings[LANG_ENG][NUM_HIERARCHY_TYPES][TH_POTION_TYPE].push_back("Potion Type");
	m_objectStrings[LANG_ENG][NUM_HIERARCHY_TYPES][TH_SHIELD_TYPE].push_back("Shield Type");
	m_objectStrings[LANG_ENG][NUM_HIERARCHY_TYPES][TH_TOOL_TYPE].push_back("Tool Type");
	m_objectStrings[LANG_ENG][NUM_HIERARCHY_TYPES][TH_WEAPON_FAMILY].push_back("Weapon Family");
	m_objectStrings[LANG_ENG][NUM_HIERARCHY_TYPES][TH_MELEE_WEAPON_TYPE].push_back("Melee Weapon Type");
	m_objectStrings[LANG_ENG][NUM_HIERARCHY_TYPES][TH_RANGED_WEAPON_TYPE].push_back("Ranged Weapon Type");
	m_objectStrings[LANG_ENG][NUM_HIERARCHY_TYPES][TH_ITEMCONTAINER_TYPE].push_back("Item Container Type");
	m_objectStrings[LANG_ENG][NUM_HIERARCHY_TYPES][TH_RESOURCE_FAMILY].push_back("Resource Family");
	m_objectStrings[LANG_ENG][NUM_HIERARCHY_TYPES][TH_RESOURCE_TYPE].push_back("Resource Type");
	m_objectStrings[LANG_ENG][NUM_HIERARCHY_TYPES][TH_TRAP_TYPE].push_back("Trap Type");

	m_objectStrings[LANG_ENG][TH_GENERIC_TYPE][GT_OB_DOOR].push_back("door");
	m_objectStrings[LANG_ENG][TH_GENERIC_TYPE][GT_OB_DOOR].push_back("A door.");
	m_objectStrings[LANG_ENG][TH_GENERIC_TYPE][GT_OB_WALL].push_back("wall");
	m_objectStrings[LANG_ENG][TH_GENERIC_TYPE][GT_OB_WALL].push_back("A dungeon wall.");
	m_objectStrings[LANG_ENG][TH_GENERIC_TYPE][GT_OB_PORTAL].push_back("portal");
	m_objectStrings[LANG_ENG][TH_GENERIC_TYPE][GT_OB_PORTAL].push_back("This leads to another dungeon level.");

	m_objectStrings[LANG_ENG][TH_ARMOR_FAMILY][AF_HEAD].push_back("head");
	m_objectStrings[LANG_ENG][TH_ARMOR_FAMILY][AF_BODY].push_back("body");
	m_objectStrings[LANG_ENG][TH_ARMOR_FAMILY][AF_HANDS].push_back("hands");
	m_objectStrings[LANG_ENG][TH_ARMOR_FAMILY][AF_LEGS].push_back("legs");
	m_objectStrings[LANG_ENG][TH_ARMOR_FAMILY][AF_FEET].push_back("feet");
	m_objectStrings[LANG_ENG][TH_INGREDIENT_FAMILY][IF_HERB].push_back("herb");
	m_objectStrings[LANG_ENG][TH_INGREDIENT_FAMILY][IF_ALCH].push_back("alchemy");
	m_objectStrings[LANG_ENG][TH_INGREDIENT_FAMILY][IF_METAL].push_back("metal");
	m_objectStrings[LANG_ENG][TH_WEAPON_FAMILY][WF_SWORD].push_back("sword");
	m_objectStrings[LANG_ENG][TH_WEAPON_FAMILY][WF_MACE].push_back("mace");
	m_objectStrings[LANG_ENG][TH_WEAPON_FAMILY][WF_SPEAR].push_back("spear");
	m_objectStrings[LANG_ENG][TH_WEAPON_FAMILY][WF_AXE].push_back("axe");
	m_objectStrings[LANG_ENG][TH_WEAPON_FAMILY][WF_HANDGUN].push_back("handgun");
	m_objectStrings[LANG_ENG][TH_RESOURCE_FAMILY][RF_PLANT].push_back("plant");
	m_objectStrings[LANG_ENG][TH_RESOURCE_FAMILY][RF_METAL].push_back("metal");

	m_objectStrings[LANG_ENG][TH_FOOD_TYPE][FT_CORPSE].push_back("corpse");
	m_objectStrings[LANG_ENG][TH_FOOD_TYPE][FT_CORPSE].push_back("A corpse. If you're daring, you can try eating it.");
	m_objectStrings[LANG_ENG][TH_FOOD_TYPE][FT_CORPSE].push_back("corpses");

	m_miscStrings[LANG_ENG][MST_SATIATION][SS_STARVING].push_back("Starving");
	m_miscStrings[LANG_ENG][MST_SATIATION][SS_VERY_HUNGRY].push_back("Very Hungry");
	m_miscStrings[LANG_ENG][MST_SATIATION][SS_HUNGRY].push_back("Hungry");
	m_miscStrings[LANG_ENG][MST_SATIATION][SS_NORMAL].push_back("");
	m_miscStrings[LANG_ENG][MST_SATIATION][SS_FULL].push_back("Full");
	m_miscStrings[LANG_ENG][MST_SATIATION][SS_VERY_FULL].push_back("Very Full");
	m_miscStrings[LANG_ENG][MST_SATIATION][SS_BLOATED].push_back("Bloated");

	m_miscStrings[LANG_ENG][MST_GENDER][GT_MALE].push_back("male");
	m_miscStrings[LANG_ENG][MST_GENDER][GT_MALE].push_back("he");
	m_miscStrings[LANG_ENG][MST_GENDER][GT_FEMALE].push_back("female");
	m_miscStrings[LANG_ENG][MST_GENDER][GT_FEMALE].push_back("she");
	m_miscStrings[LANG_ENG][MST_GENDER][GT_NONE].push_back("none");
	m_miscStrings[LANG_ENG][MST_GENDER][GT_NONE].push_back("it");

	m_miscStrings[LANG_ENG][MST_HEALTH][HS_DEAD].push_back("dead");
	m_miscStrings[LANG_ENG][MST_HEALTH][HS_NEAR_DEATH].push_back("near death");
	m_miscStrings[LANG_ENG][MST_HEALTH][HS_HEAVILY_WOUNDED].push_back("heavily wounded");
	m_miscStrings[LANG_ENG][MST_HEALTH][HS_MODERATELY_WOUNDED].push_back("moderately wounded");
	m_miscStrings[LANG_ENG][MST_HEALTH][HS_SLIGHTLY_WOUNDED].push_back("slightly wounded");
	m_miscStrings[LANG_ENG][MST_HEALTH][HS_NOT_WOUNDED].push_back("not wounded");

	m_miscStrings[LANG_ENG][MST_STATUS_EFFECT][SE_POISON].push_back("poison");
	m_miscStrings[LANG_ENG][MST_STATUS_EFFECT][SE_POISON].push_back("poison");
	m_miscStrings[LANG_ENG][MST_STATUS_EFFECT][SE_INVIS].push_back("invisible");
	m_miscStrings[LANG_ENG][MST_STATUS_EFFECT][SE_INVIS].push_back("invis");

	m_miscStrings[LANG_ENG][MST_STAT][STR].push_back("strength");
	m_miscStrings[LANG_ENG][MST_STAT][COM].push_back("composure");
	m_miscStrings[LANG_ENG][MST_STAT][NIM].push_back("nimbleness");
	m_miscStrings[LANG_ENG][MST_STAT][LOR].push_back("lore");
	m_miscStrings[LANG_ENG][MST_STAT][PER].push_back("perception");
	m_miscStrings[LANG_ENG][MST_STAT][STR].push_back("STR");
	m_miscStrings[LANG_ENG][MST_STAT][COM].push_back("COM");
	m_miscStrings[LANG_ENG][MST_STAT][NIM].push_back("NIM");
	m_miscStrings[LANG_ENG][MST_STAT][LOR].push_back("LOR");
	m_miscStrings[LANG_ENG][MST_STAT][PER].push_back("PER");

	m_miscStrings[LANG_ENG][MST_LOCK][LT_ROUND].push_back("round");
	m_miscStrings[LANG_ENG][MST_LOCK][LT_SQUARE].push_back("square");

	m_miscStrings[LANG_ENG][MST_STATUS][CURSED].push_back("cursed");
	m_miscStrings[LANG_ENG][MST_STATUS][UNCURSED].push_back("uncursed");
	m_miscStrings[LANG_ENG][MST_STATUS][BLESSED].push_back("blessed");
	m_miscStrings[LANG_ENG][MST_STATUS][CURSED].push_back("*C*");
	m_miscStrings[LANG_ENG][MST_STATUS][UNCURSED].push_back("*U*");
	m_miscStrings[LANG_ENG][MST_STATUS][BLESSED].push_back("*B*");

	m_miscStrings[LANG_ENG][MST_GRIP][GT_ONE].push_back("This weapon is wielded with one hand.");
	m_miscStrings[LANG_ENG][MST_GRIP][GT_ONE_FIVE].push_back("This weapon can be wielded with one hand, but will receive benefits from holding it with two.");
	m_miscStrings[LANG_ENG][MST_GRIP][GT_TWO].push_back("This weapon requires two hands to wield.");

	m_miscStrings[LANG_ENG][MST_RECIPE][RT_POTION_HEAL].push_back("healing potion");

	m_miscStrings[LANG_ENG][MST_DUNGEON][DT_DUNGEON].push_back("Dungeon");
	m_miscStrings[LANG_ENG][MST_DUNGEON][DT_DUNGEON].push_back("D");

	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_PREFIX][MWP_DULL].push_back("dull");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_PREFIX][MWP_HEAVY].push_back("heavy");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_PREFIX][MWP_SHARP].push_back("sharp");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_PREFIX][MWP_BRUTAL].push_back("brutal");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_PREFIX][MWP_FINE].push_back("fine");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_PREFIX][MWP_MASTERWORK].push_back("masterwork");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_PREFIX][MWP_FLAMING].push_back("flaming");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_PREFIX][MWP_POISONOUS].push_back("poisonous");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_PREFIX][MWP_DULL].push_back("This weapon has a dull blade.");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_PREFIX][MWP_HEAVY].push_back("This weapon is unusually heavy.");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_PREFIX][MWP_SHARP].push_back("This weapon is very sharp.");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_PREFIX][MWP_BRUTAL].push_back("This weapon has brutal barbs on it.");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_PREFIX][MWP_FINE].push_back("This weapon has the mark of a fine craftsman.");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_PREFIX][MWP_MASTERWORK].push_back("This weapon has the mark of a master craftsman.");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_PREFIX][MWP_FLAMING].push_back("Magical flames emanate from the blade.");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_PREFIX][MWP_POISONOUS].push_back("Poison is dripping from the blade.");

	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_SUFFIX][MWS_OF_LUST].push_back("of lust");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_SUFFIX][MWS_OF_GLUTTONY].push_back("of gluttony");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_SUFFIX][MWS_OF_GREED].push_back("of greed");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_SUFFIX][MWS_OF_SLOTH].push_back("of sloth");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_SUFFIX][MWS_OF_WRATH].push_back("of wrath");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_SUFFIX][MWS_OF_ENVY].push_back("of envy");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_SUFFIX][MWS_OF_PRIDE].push_back("of pride");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_SUFFIX][MWS_OF_LUST].push_back("This weapon deals extra damage to enemies of the opposite sex.");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_SUFFIX][MWS_OF_GLUTTONY].push_back("This weapon makes you hungrier than normal.");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_SUFFIX][MWS_OF_GREED].push_back("This weapon helps you find more gold.");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_SUFFIX][MWS_OF_SLOTH].push_back("This weapon swings much slower than normal.");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_SUFFIX][MWS_OF_WRATH].push_back("This weapon is magically enhanced to cause extraordinary damage.");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_SUFFIX][MWS_OF_ENVY].push_back("This weapon does more damage to enemies that are a higher level than you.");
	m_miscStrings[LANG_ENG][MST_MELEE_WEAPON_SUFFIX][MWS_OF_PRIDE].push_back("Wielding this weapon causes you to be overconfident in your abilities, causing you to miss more.");

	//m_miscStrings[LANG_ENG][MST_RANGED_WEAPON_PREFIX][RWP_].push_back("");
	//m_miscStrings[LANG_ENG][MST_RANGED_WEAPON_SUFFIX][RWS_].push_back("");

	m_miscStrings[LANG_ENG][MST_TOOL_PREFIX][TP_NOVICE].push_back("novice's");
	m_miscStrings[LANG_ENG][MST_TOOL_PREFIX][TP_ADEPT].push_back("adept's");
	m_miscStrings[LANG_ENG][MST_TOOL_PREFIX][TP_EXPERT].push_back("expert's");
	m_miscStrings[LANG_ENG][MST_TOOL_PREFIX][TP_NOVICE].push_back("This set of tools was made for a novice.");
	m_miscStrings[LANG_ENG][MST_TOOL_PREFIX][TP_ADEPT].push_back("This set of tools was made for an adept.");
	m_miscStrings[LANG_ENG][MST_TOOL_PREFIX][TP_EXPERT].push_back("This set of tools was made for an expert.");

	//m_miscStrings[LANG_ENG][MST_SHIELD_PREFIX][SP_].push_back("");
	//m_miscStrings[LANG_ENG][MST_SHIELD_SUFFIX][SS_].push_back("");

	//m_miscStrings[LANG_ENG][MST_ARMOR_PREFIX][AP_].push_back("");
	//m_miscStrings[LANG_ENG][MST_ARMOR_SUFFIX][AS_].push_back("");

	m_miscStrings[LANG_ENG][MST_EQUIPMENT][EL_LEFT_HAND].push_back("Left Hand");
	m_miscStrings[LANG_ENG][MST_EQUIPMENT][EL_RIGHT_HAND].push_back("Right Hand");
	m_miscStrings[LANG_ENG][MST_EQUIPMENT][EL_LEFT_HAND].push_back("LH");
	m_miscStrings[LANG_ENG][MST_EQUIPMENT][EL_RIGHT_HAND].push_back("RH");
	m_miscStrings[LANG_ENG][MST_EQUIPMENT][EL_HEAD].push_back("Head");
	m_miscStrings[LANG_ENG][MST_EQUIPMENT][EL_BODY].push_back("Body");
	m_miscStrings[LANG_ENG][MST_EQUIPMENT][EL_HANDS].push_back("Hands");
	m_miscStrings[LANG_ENG][MST_EQUIPMENT][EL_LEGS].push_back("Legs");
	m_miscStrings[LANG_ENG][MST_EQUIPMENT][EL_FEET].push_back("Feet");

	m_miscStrings[LANG_ENG][MST_FILTER][FT_MELEE_WEAPON].push_back("melee weapons");
	m_miscStrings[LANG_ENG][MST_FILTER][FT_RANGED_WEAPON].push_back("ranged weapons");
	m_miscStrings[LANG_ENG][MST_FILTER][FT_SHIELD].push_back("shields");
	m_miscStrings[LANG_ENG][MST_FILTER][FT_AMMO].push_back("ammo");
	m_miscStrings[LANG_ENG][MST_FILTER][FT_ARMOR].push_back("armor");
	m_miscStrings[LANG_ENG][MST_FILTER][FT_TOOL].push_back("tools");
	m_miscStrings[LANG_ENG][MST_FILTER][FT_POTION].push_back("potions");
	m_miscStrings[LANG_ENG][MST_FILTER][FT_SCROLL].push_back("scrolls");
	m_miscStrings[LANG_ENG][MST_FILTER][FT_INGREDIENT].push_back("ingredients");
	m_miscStrings[LANG_ENG][MST_FILTER][FT_FOOD].push_back("food");
	m_miscStrings[LANG_ENG][MST_FILTER][FT_MISC].push_back("misc");

	m_miscStrings[LANG_ENG][MST_SKILL][SKI_EXPLOIT].push_back("exploitation");
	m_miscStrings[LANG_ENG][MST_SKILL][SKI_EXPLOIT].push_back("You are more likely to score a critical hit.");
	m_miscStrings[LANG_ENG][MST_SKILL][SKI_FINESSE].push_back("finesse");
	m_miscStrings[LANG_ENG][MST_SKILL][SKI_FINESSE].push_back("Your critical attacks do more damage.");
	m_miscStrings[LANG_ENG][MST_SKILL][SKI_STEALTH].push_back("stealth");
	m_miscStrings[LANG_ENG][MST_SKILL][SKI_STEALTH].push_back("You are harder to detect.");
}

StringLib::~StringLib() {
}

std::string StringLib::getTextString(StringType type, ...) const {
	if(std::count(m_textStrings.at(m_languageType).at(type).begin(), m_textStrings.at(m_languageType).at(type).end(), '\t') == 0)
		return m_textStrings.at(m_languageType).at(type);
	va_list vars;
    va_start(vars, type); 
	std::stringstream output, ss(m_textStrings.at(m_languageType).at(type));
	std::vector<std::string> tokens;
	std::string item;
	while(std::getline(ss, item, '\t')) {
		tokens.push_back(item);
	}

	if(m_textStrings.at(m_languageType).at(type).at(m_textStrings.at(m_languageType).at(type).size()-1) == '\t')
		tokens.push_back(std::string(""));
	for(unsigned int i = 0; i < tokens.size()-1; i++) {
		std::string swap = std::string(va_arg(vars, const char *));
		output << checkTokenA(tokens[i], swap) << swap;
	}
	output << tokens[tokens.size()-1];
	va_end(vars);
	return output.str();
}

std::string StringLib::checkTokenA(std::string s, std::string name) {
	if(s.size() > 1 && s.at(s.size()-2) == '\n') {
		char c = name.at(0);
		if(c == '\r')
			c = name.at(2);
		if(c >= '0' && c <= '9')
			s = s.replace(s.size()-2, 2, "");
		else
			s = s.replace(s.size()-2, 1, (Util::an(c) ? "an" : "a"));
	}
	return s;
}

std::string StringLib::capitalize(std::string s) {
	char c = s.at(0);
	if(c >= 'a' && c <= 'z') {
		c = c-'a'+'A';
		s.replace(0, 1, 1, c);
	}
	return s;
}

void StringLib::setPlayerName(std::string name) {
	for(int i = 0; i < NUM_LANGUAGE_TYPES; i++)
		m_objectStrings[LanguageType(i)][TH_PLAYER_TYPE][i].push_back(name);
}

std::string StringLib::getObjectString(TypeHierarchy category, int type, int index, bool cap) const {
	std::string str = m_objectStrings.at(m_languageType).at(category).at(type).at(index);
	if(cap)
		str = capitalize(str);
	return str;
}

std::string StringLib::getMiscString(MiscStringType category, int type, int index, bool cap) const {
	std::string str = m_miscStrings.at(m_languageType).at(category).at(type).at(index);
	if(cap)
		str = capitalize(str);
	return str;
}

void StringLib::setObjectString(TypeHierarchy category, int type, std::string string) {
	for(int i = 0; i < NUM_LANGUAGE_TYPES; i++)
		m_objectStrings[LanguageType(i)][category][type].push_back(string);
}

void StringLib::setMiscString(MiscStringType category, int type, std::string string) {
	for(int i = 0; i < NUM_LANGUAGE_TYPES; i++)
		m_miscStrings[LanguageType(i)][category][type].push_back(string);
}
